<style lang="scss">
	page{
		background: #F5F5F5;
		// padding-top: 30upx;
		.all{
			width: 750upx;
			.module{
				width: 700upx;
				padding: 25upx;
				background: #FFFFFF;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.module_box{
					margin-left: 18upx;
					.module_box_image{
						width: 332upx;
						height: 196upx;
					}
					.module_box_text{
						position: absolute;
						width: 332upx;
						width: 196upx;
						z-index: 1;
						.module_box_title{
							width: 332upx;
							text-align: center;
							height: 36upx;
							font-size: 26upx;
							font-weight: 400;
							color: #333;
							line-height: 36upx;
							margin-top: 42upx;
						}
						.module_box_money{
							width: 332upx;
							text-align: center;
							height: 56upx;
							font-size: 40upx;
							font-weight: bold;
							color: #333;
							line-height: 56upx;
							margin-top: 10upx;
						}
						.module_box_money_new{
							width: 332upx;
							text-align: center;
							font-size: 24upx;
							color: #FFFFFF;
							line-height: 56upx;
							margin-top: 0upx;
						}
					}
				}
			}
			
			.list{
				margin-top: 22upx;
				background: #FFFFFF;
				width: 690upx;
				padding: 0 30upx;
				.list_box{
					width: 690upx;
					padding: 28upx 0;
					display: flex;
					.list_box_text{
						width: 345upx;
						height: 44upx;
						font-size: 32upx;
						font-weight: bold;
						color: #333333;
						line-height: 44upx;
					}
					.list_box_image{
						width: 22upx;
						height: 32upx;
						margin-left: 23upx;
						margin-top: 10upx;
					}
					.list_box_content{
						width: 300upx;
						height: 44upx;
						font-size: 32upx;
						font-weight: 400;
						color: #A02731;
						line-height: 44upx;
						text-align: right;
					}
				}
			}
			.tabBar{
				width: 750upx;
				height: 100upx;
				position: fixed;
				bottom: 0;
				display: flex;
				z-index: 1;
				background: #FFFFFF;
				.tabBar_box{
					width: 187.5upx;
					margin-top: 16upx;
					.tabBar_box_image{
						width: 44upx;
						height: 44upx;
						margin-left: 71.75upx;
					}
					.tabBar_box_images{
						width: 66upx;
						height: 66upx;
						border-radius: 50%;
						border: 6upx solid rgba(206, 206, 206, 0.11);
						// margin-top: -10upx;
						margin-left: 60.75upx;
					}
					.tabBar_box_text{
						width: 187.5upx;
						text-align: center;
						height: 28upx;
						font-size: 20upx;
						font-weight: bold;
						color: #A02731;
						line-height: 28upx;
					}
					.tabBar_box_text_new{
						width: 187.5upx;
						text-align: center;
						height: 28upx;
						font-size: 20upx;
						font-weight: 400;
						color: #666666;
						line-height: 28upx;
					}
				}
			}
			.fenxiang{
				.fenxiang_list{
					width: 700upx;
					padding: 25upx;
					.list{
						width: 690upx;
						padding: 30upx;
						border-bottom: 1upx solid #DDDDDD;
						display: flex;
						.list_image{
							width: 80upx;
							height: 80upx;
							border-radius: 50%;
						}
						.list_text{
							margin-left: 24upx;
							margin-top: 0;
							.list_text_name{
								width: 420upx;
								display: flex;
								.list_text_name_text_new{
									max-width: 220upx;
									height: 42upx;
									font-size: 30upx;
									font-weight: bold;
									color: #333333;
									line-height: 42upx;
									overflow:hidden;
									text-overflow:ellipsis;
									white-space:nowrap;
									display: inline-block;
								}
								.list_text_name_text{
									display: inline-block;
									width: 200upx;
									height: 36upx;
									line-height: 42upx;
									font-size: 26upx;
									font-weight: 400;
									margin-left: 10upx;
									overflow:hidden;
									text-overflow:ellipsis;
									white-space:nowrap;
								}
							}
							.list_text_sl{
								width: 420upx;
								height: 34upx;
								font-size: 24upx;
								font-weight: 400;
								color: #A02731;
								line-height: 34upx;
								margin-top: 8upx;
							}
						}
						.list_anniu{
							width: 148upx;
							height: 60upx;
							background: #A02731;
							border: 2upx solid #A02731;
							text-align: center;
							line-height: 60upx;
							font-size: 24upx;
							color: #FFFFFF;
							margin-top: 22upx;
						}
					}
				}
				background: #fff;
				margin-top: 20upx;
				.fenxiang_top{
					.fenxiang_top_box{
						width: 50%;
						text-align: center;
						line-height: 100upx;
						height: 100upx;
						color: #333;
						font-size: 30upx;
						font-weight: bold;
						border-bottom: 1upx solid #333;
					}
					.fenxiang_top_boxs{
						width: 50%;
						font-size: 30upx;
						text-align: center;
						line-height: 100upx;
						height: 100upx;
						color: #999;
						border-bottom: 1upx solid #eee;
					}
					display: flex;
					width: 750upx;
					border-bottom: 1upx solid #eee;
				}
			}
		}
	}
</style>
<template>
	<view class="all">
		<view class="module">
			<view class="module_box" @click="my_order">
				<!-- @click="my_wallet(1)" -->
				<view class="module_box_text" >
					<view class="module_box_title">团队总业绩</view>
					<view class="module_box_money">{{list_data.today_money}}</view>
				</view>
				<view class="module_box_image"></view>
				<!-- <image class="module_box_image" src="../../static/17.png"></image> -->
			</view>
			<view class="module_box" @click="my_active">
				<!-- @click="my_wallet(2)" -->
				<view class="module_box_text">
					<view class="module_box_title">累计总收益</view>
					<view class="module_box_money">{{list_data.total_income}}</view>
				</view>
				<view class="module_box_image"></view>
				<!-- <image class="module_box_image" src="../../static/15.png"></image> -->
			</view>
			<view class="module_box">
				<view class="module_box_text">
					<view class="module_box_title">销售提成奖励</view>
					<view class="module_box_money">{{list_data.sales_money}}</view>
					<!-- <view class="module_box_money_new">（团队今日活跃人数：{{list_data.today_user}}单）</view> -->
				</view>
				<view class="module_box_image"></view>
				<!-- <image class="module_box_image" src="../../static/14.png"></image> -->
			</view>
			<view class="module_box">
				<view class="module_box_text">
					<view class="module_box_title">代理提成奖励</view>
					<view class="module_box_money">{{list_data.team_money}}</view>
					<!-- <view class="module_box_money_new">（团队今日活跃人数：{{list_data.today_user}}单）</view> -->
				</view>
				<view class="module_box_image"></view>
				<!-- <image class="module_box_image" src="../../static/14.png"></image> -->
			</view>
			<!-- <view class="module_box" @click="record">
				<view class="module_box_text">
					<view class="module_box_title">余额记录</view>
					<view class="module_box_money">查看记录</view>
				</view>
				<image class="module_box_image" src="../../static/16.png"></image>
			</view> -->
		</view>
		<view class="list">
			<!-- <view @click="withdraw" class="list_box" style="border-bottom: 1upx solid #DDDDDD;">
				<view class="list_box_text">提现</view>
				<view class="list_box_content"></view>
				<image class="list_box_image" src="../../static/13.png"></image>
			</view> -->
			<!-- <view class="list_box" @click="my_team" style="border-bottom: 1upx solid #DDDDDD;">
				<view class="list_box_text">我的团队</view>
				<view class="list_box_content"></view>
				<view class="list_box_content" v-if="list_data.check > 0">{{list_data.check}}人未审核</view>
				<view class="list_box_content" v-if="list_data.check == 0"></view>
				<image class="list_box_image" src="../../static/13.png"></image>
			</view> -->
			<view class="list_box" @click="setClipboardData_tap(code)">
				<view class="list_box_text">我的推荐码</view>
				<view class="list_box_content" style="color: #999999;">{{code}}</view>
				<image class="list_box_image" src="../../static/13.png"></image>
			</view>
		</view>
		<view class="fenxiang">
			<view class="fenxiang_top">
				<view :class="fenxiang == 0?'fenxiang_top_box':'fenxiang_top_boxs'" @click="fenxiang_tap(0)"> 直接分享 </view>
				<view :class="fenxiang == 1?'fenxiang_top_box':'fenxiang_top_boxs'" @click="fenxiang_tap(1)"> 我的团队 </view>
			</view>
			<view class="fenxiang_list">
				<view v-if="fenxiang == 0">
					<view class="list" v-if="direct_data.length != 0" v-for="(item,index) in direct_data" :key="index">
						<image class="list_image" :src="item.avatar_url"></image>
						<view class="list_text">
							<view class="list_text_name"> <view class="list_text_name_text_new"> {{item.account}} </view> 
							</view>
							<view class="list_text_sl">级别：{{item.rank}}</view>
							<view class="list_text_sl">{{item.phone}}</view>
						</view>
					</view>
				</view>
				<view v-if="fenxiang == 1">
					<view class="list" v-if="friends_data.length != 0" v-for="(item,index) in friends_data" :key="index">
						<image class="list_image" :src="item.avatar_url"></image>
						<view class="list_text">
							<view class="list_text_name"> <view class="list_text_name_text_new"> {{item.account}} </view> 
							</view>
							<view class="list_text_sl">级别：{{item.rank}}</view>
							<view class="list_text_sl">{{item.phone}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import urlConfig from 'common/config.js';
	export default {
		data() {
			return {
				list_data:{},
				avatar_url:'',
				code:'',
				fenxiang:0,
				direct_data:[],
				page:1,
				friends_data:[]
			}
		},
		onShow() {
			if( !uni.getStorageSync('access_token') ) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					cancelText:'返回',
					confirmColor:'#A02731',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.reLaunch({
								url:'../disembark/disembark'
							})
						} else if (res.cancel) {
							wx.closeWindow()
						}
					}
				});
			}
			this.friend_api()
			this.person_api()
			this.page = 1
			this.direct_team_api()
			this.friends_team_api()
		},
		methods: {
			//我的团队
			friends_team_api() {
				var that = this
				that.$request(that.$Api.friends_team_api, {
					access_token: uni.getStorageSync('access_token'),
					page:that.page
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.friends_data = res.data.data.list
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			//我的直推
			direct_team_api() {
				var that = this
				that.$request(that.$Api.direct_team_api, {
					access_token: uni.getStorageSync('access_token'),
					page:that.page
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.direct_data = res.data.data.list
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			fenxiang_tap(num) {
				this.page = 1
				this.fenxiang = num
				if( this.fenxiang == 0 ) {
					this.direct_team_api()
				}else{
					this.friends_team_api()
				}
			},
			setClipboardData_tap(code) {
				uni.setClipboardData({
					data: code,
					success: function () {
						console.log('success');
					}
				});
			},
			record() {
				uni.navigateTo({
					url:'../record/record'
				})
			},
			tuijian() {
				var that = this
				uni.setClipboardData({
				data: that.code,
				success:function(data){
					 uni.showToast({
						 title: '复制成功',
						 duration: 1000,
						 icon:'none'
					 });
				}, fail:function(err){
				}, complete:function(res){
				} })
			},
			//个人中心
			person_api() {
				var that = this
				uni.showLoading({
				    title: '加载中'
				});
				uni.request({
					url: urlConfig.Url + 'api/user/person',
					data:{
						access_token:uni.getStorageSync('access_token')
					},
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: (res) => {
						uni.hideLoading();
						if (res.data.code == 0) {
							that.avatar_url = res.data.data.list.avatar_url
							that.code = res.data.data.list.code
						} else if (res.data.code == -1) {	
						} else {
							uni.showToast({
								title: res.data.msg,
								duration: 2000,
								icon: 'none'
							});
						}
					}
				});
			},
			//获取首页
			friend_api() {
				var that = this
				that.$request(that.$Api.friends_index_api, {
					access_token: uni.getStorageSync('access_token'),
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.list_data = res.data.data.data
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			//分享海报
			share_banner() {
				var token = uni.getStorageSync('access_token')
				uni.navigateTo({
					url:'../share_banner/share_banner?token='+token
				})
			},
			//提现
			withdraw() {
				var token = uni.getStorageSync('access_token')
				uni.navigateTo({
					url:'../withdraw/withdraw?token='+token
				})
			},
			//我的团队
			my_team() {
				var token = uni.getStorageSync('access_token')
				uni.navigateTo({
					url:'../my_team_new/my_team_new?token='+token
				})
			},
			//直推
			my_team_new() {
				uni.navigateTo({
					url:'../my_team_new/my_team_new'
				})
			},
			my_all() {
				var token = uni.getStorageSync('access_token')
				uni.navigateTo({
					url:'../my_all/my_all'
				})
			},
			my_active() {
				var token = uni.getStorageSync('access_token')
				uni.navigateTo({
					url:'../my_active/my_active'
				})
			},
			my_order() {
				var token = uni.getStorageSync('access_token')
				uni.navigateTo({
					url:'../my_order_data/my_order_data'
				})
			},
			//我的钱包
			my_wallet(num) {
				var token = uni.getStorageSync('access_token')
				// 1 佣金 2提现
				uni.navigateTo({
					url:'../my_wallet/my_wallet?key='+num+'&token='+token
				})
			},
			//tabBar_tap
			tabBar_tap(num) {
				var token = uni.getStorageSync('access_token')
				if( num == 0 ) {
					//首页
					uni.reLaunch({
						url:'../index/index?token='+token
					})
				} else if( num == 1 ) {
					//我的分享
				} else if( num == 2 ) {
					//订单
					uni.reLaunch({
						url:'../my_order/my_order?token='+token
					})
				} else if( num == 3 ) {
					//我的
					uni.reLaunch({
						url:'../my/my?token='+token
					})
				}
			},
		},
		onReachBottom() {
			var that = this
			that.page++
			if( that.fenxiang == 0 ) {
				that.$request(that.$Api.direct_team_api, {
					access_token: uni.getStorageSync('access_token'),
					page:that.page
				}, "POST").then(res => {
					if (res.data.code == 0) {
						if( res.data.data.list.length != 0 ) {
							that.direct_data = that.direct_data.concat(res.data.data.list)
						}
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			}else{
				that.$request(that.$Api.friends_team_api, {
					access_token: uni.getStorageSync('access_token'),
					page:that.page
				}, "POST").then(res => {
					if (res.data.code == 0) {
						if( res.data.data.list.length != 0 ) {
							that.friends_data = that.friends_dataconcat(res.data.data.list)
						}
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			}
		}
	}
</script>
















